package View.GeneralManagerView.VariablePanel;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JFormattedTextField;
import javax.swing.text.DateFormatter;


public class dataTextField extends JFormattedTextField implements InputFieldWithDefaultValue{
	private static DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	private static DateFormatter df = new DateFormatter(format);
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public dataTextField(){
		super(df);
		Date d = (new Date());		
		setText(format.format(d));	
	}
	
	@Override
	public Object getFillingIn() {
		if(this.getText().equals(""))
			return null;
		else
			try {
				return format.parseObject(this.getText());
			} catch (ParseException e) {
				e.printStackTrace();
				return null;
			}
	}

	@Override
	public String getFormatClassName() {
		return this.getClass().getName();
	}

	@Override
	public void setDefaultValue(String x){
		this.setText(x);
	}


}
